package I;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 存款界面
 */
public class SavePanel extends JPanel implements ActionListener {
    private ATMFrame atmFrame;
    private ImageIcon sureImg= new ImageIcon("picture/buttonSure.jpg");
    private JLabel  sss = new JLabel("存款金额：");
    private JTextField sssa=new JTextField();
    private Font font = new Font("微软雅黑",Font.BOLD,25);
    private JButton sureBth= new JButton(sureImg);
    public SavePanel(ATMFrame atmFrame){
        this.atmFrame = atmFrame;
        this.setLayout(null);
        sssa.setBounds(400,200,200,50);
        sssa.setFont(font);
        sss.setBounds(250,200,330,50);
        sss.setFont(font);
        sureBth.setBounds(400,350,150,50);
        sureBth.addActionListener(this);
        this.add(sss);
        this.add(sssa);
        this.add(sureBth);


        this.setOpaque(false);


    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource()==sureBth){
            User user = atmFrame.getLoginUser();
            try {
                user.setBlance(user.getBlance()+Double.parseDouble(sssa.getText()));
            }catch (NumberFormatException a){
                System.out.println("请输入数字：");
            }
            atmFrame.switchPanel("menu");
        }
    }
}
